package com.learn.demo.mvc.action;

import com.learn.demo.service.QueryService;
import com.learn.springframework.annotation.Autowired;
import com.learn.springframework.annotation.Controller;
import com.learn.springframework.annotation.RequestMapping;
import com.learn.springframework.annotation.RequestParam;
import com.learn.springframework.v3.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/")
public class PageAction {

    @Autowired
    private QueryService queryService;

    @RequestMapping("/first.html")
    public ModelAndView query(@RequestParam("teacher") String teacher) {
        String result = queryService.query(teacher);
        Map<String, Object> model = new HashMap<String, Object>();
        model.put("teacher", teacher);
        model.put("data", result);
        model.put("token", "123456");
        return new ModelAndView("first.html");
    }
}
